<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/echarts.js"></script>
    <script src="js/jquery-3.6.0.min.js"></script>
  <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head>
<body>
<div id="dv1" style="width: 800px;height:600px;"></div>
<script>
    var chartDom = document.getElementById('dv1');
    var myChart = echarts.init(chartDom);
    var option;

    option = {
        title: {
            text: '信息工程学院各班分布',
            subtext: '饼状图',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'left'
        },
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: '50%',
                data: [
                    { value: 1, name: '物联网工程一班' },
                    { value: 1, name: '物联网工程二班' },
                    { value: 2, name: '软件工程一班' },
                    { value: 1, name: '软件工程二班' },
                    //{ value: 300, name: 'Video Ads' }
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    //3.使用刚指定的配置项和数据显示图表。
    option && myChart.setOption(option);
    //ajax 请求接口
    //ajax 请求接口
    //ajax 请求接口
    $.get("/api/grade/echarts.do", function (res) {
        if (res.code == 200) {
                option.series[0].data[0].value= res.data.nums;
                option.series[0].data[1].value= res.data.nums;
            myChart.setOption(option);
        }
    })
</script>
</body>
</html>